﻿@{
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}
@{
    List<ConsumeSys.Model.ConsumeType> list = (List<ConsumeSys.Model.ConsumeType>)ViewData["list"];    
}
<div>
    <table>
        <tr>
            <td>上级分类：</td>
            <td>
                <select name="ct_ParentId">
                    <option value="0">顶级分类</option>
                    @{
                        if (list != null && list.Count > 0)
                        {
                            foreach (ConsumeSys.Model.ConsumeType item in list)
                            {
                                <option value="@item.id">@item.ct_TypeName</option>
                            }
                        }
                     }
                </select>
            </td>
        </tr>
        <tr>
            <td>分类名称：</td>
            <td>
                <input type="text" name="ct_TypeName" value="" /></td>
        </tr>
        <tr>
            <td>简介：</td>
            <td>
                <textarea rows="4" cols="30" name="ct_TypeAbbreviation"></textarea></td>
        </tr>
        <tr>
            <td>备注：</td>
            <td>
                <textarea rows="4" cols="30" name="ct_Remark"></textarea></td>
        </tr>
        <tr>
            <td></td>
            <td>
                <input type="button" value="提交" onclick="Add()" /></td>
        </tr>
    </table>
    <script type="text/javascript">
        function Add() {
            $.ajax({
                type: "POST",
                url: "/Consume/GetAEConsumeType",
                data: {
                    ct_ParentId: $("[name=ct_ParentId] option:selected").val(),
                    ct_TypeName: $("[name=ct_TypeName]").val(),
                    ct_TypeAbbreviation: $("[name=ct_TypeAbbreviation]").val(),
                    ct_Remark: $("[name=ct_Remark]").val()
                },
                success: function (msg) {
                    if (msg == "success") {
                        S_success();
                    } else {
                        E_error();
                    }
                }
            });
        }
    </script>
</div>
